package per.zhang.serverPrevioder.dto.respone;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.format.annotation.DateTimeFormat;
import per.zhang.serverPrevioder.entity.Appointment;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.Date;

/**
 * @auther zhang
 * @ TO DO
 * @creatTime 2021/1/26 17:32
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AppointmentRespondDTO implements Serializable {

    /**
     * 预约id
     */
    private Integer appointmentId;

    /**
     * 用户id
     */
    private String userId;

    /**
     * 预约人名字
     */
    private String userName;

    /**
     * 用户联系方式
     */
    private String callphone;

    /**
     * 疫苗id
     */
    private Integer vaccineId;


    /**
     * 疫苗名字
     */
    private String vaccinaName;

    /**
     * 创建时间
     */
    @DateTimeFormat(pattern = "YYYY-MM-DD hh:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date creatTime;

    /**
     * 预约时间
     */
    @DateTimeFormat(pattern = "YYYY-MM-DD hh:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date appointmentTime;

    /**
     * 预约状态，0表示已预约，1表示已接种，2表示已取消,3表示已过期
     */
    private String state;

    public AppointmentRespondDTO(Appointment appointment, String vaccinaName, Integer vaccinaId) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        PropertyUtils.copyProperties(this,appointment);
        this.vaccinaName = vaccinaName;
        this.vaccineId = vaccinaId;
    }

}
